#include <iostream>
#include <string>
#include <vector>

using namespace std;

class Solution {
public:
    double findMaxAverage(vector<int>& nums, int k) {
        double maxAverage = 0;

        if (nums.size() < k) {
            return maxAverage;
        }

        double sum = 0;
        for (int idx = 0; idx < k; idx++) {
            sum += nums[idx];
        }
        maxAverage = sum / k;

        for (int idx = 0; idx < nums.size() - k; idx++) {
            sum -= nums[idx];
            sum += nums[idx + k];
            maxAverage = (sum / k) > maxAverage? (sum / k):maxAverage;
        }
        return maxAverage;   
    }
};

int main()
{
    Solution s;
    vector<int> vt{5};
    cout << s.findMaxAverage(vt, 1) << endl;

    return 0;
}